//
//  StarMovieCell.m
//  LiveStar
//
//  Created by 漪珊 on 2016/12/12.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "StarMovieCell.h"
#import "StarInfoModel.h"

@implementation StarMovieCell
- (void)awakeFromNib {
    [super awakeFromNib];
    kImageViewRadius(self.starIcon, self.starIcon.width/2);
    kButtonRadius(self.focusBtn, self.focusBtn.height/2);
    kLabelRadius(self.advanceNum, self.advanceNum.height/2);
}
- (void)setInfoModel:(StarInfoModel *)infoModel {
    _infoModel = infoModel;
    [self.starIcon sd_setImageWithURL:[NSURL URLWithString:infoModel.u_avatar] placeholderImage:kPlACE_ICON];
    self.StarName.text = infoModel.s_name;
    self.focusNum.text = [NSString stringWithFormat:@"关注人数%@人",KString(infoModel.s_booked)] ;
    if ([KString(infoModel.booked) isEqualToString:@"10"]) {
        [self.focusBtn setTitle:@"已关注" forState:UIControlStateNormal];
        [self.focusBtn setTitleColor:[UIColor colorWithHexString:@"04DD98"] forState:UIControlStateNormal];
        self.focusBtn.backgroundColor = [UIColor whiteColor];
    } else {
        [self.focusBtn setTitle:@"+ 关注" forState:UIControlStateNormal];
        [self.focusBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.focusBtn.backgroundColor = [UIColor colorWithHexString:@"04DD98"];
    }
    if ([infoModel.live integerValue]) { //有直播
        self.liveStateImgView.image = kSET_IMAGE(@"LiveState");
        self.exitLabel.text = @"直播";
        self.advanceNum.hidden = YES;
    } else {
        if ([infoModel.advance integerValue]) { //有预告
            self.liveStateImgView.hidden = YES;
            self.advanceNum.hidden = NO;
            self.advanceNum.text = KString(infoModel.advance);
            self.exitLabel.text = @"预告";
        } else {
            self.liveStateImgView.hidden = YES;
            self.advanceNum.hidden = YES;
            self.exitLabel.hidden = YES;
        }
    }

}

//关注
- (IBAction)focusClick:(id)sender {
    [self.delegate focusStar:self];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
